﻿using M_Quality.API.Application.Command.RawMaterialQualityCommand;
using M_Quality.Repository.Interface;
using MediatR;

namespace M_Quality.API.Application.CommandHandler.RawMaterialQualityCommandHandler
{
    public class RemoveRMQCommandHandler : IRequestHandler<RemoveRMQCommand, int>
    {
        private readonly IRawMaterialQualityRepository _repository;

        public RemoveRMQCommandHandler(IRawMaterialQualityRepository repository)
        {
            _repository = repository;
        }

        public async Task<int> Handle(RemoveRMQCommand request, CancellationToken cancellationToken)
        {
            var ss = await _repository.GetModelAsync(request.RawMaterialQualityId);
            ss.IsDeleted = true;
            return await _repository.UpdateAsync(ss);
        }
    }
}
